package com.woniuxy.finance.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.commons.utils.ResStatus;
import com.woniuxy.commons.utils.ResponseResult;
import com.woniuxy.finance.dao.TransferDao;
import com.woniuxy.finance.entity.Transfer;
import com.woniuxy.finance.service.TransferService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @ClassName TransferServiceImpl
 * @Description TODO
 * @Author Administrator
 * @Date 2022/6/10 14:32
 * @Version 1.0
 */
@Service
public class TransferServiceImpl implements TransferService {
    @Resource
    private TransferDao transferDao;

    @Override
    public ResponseResult<List<Transfer>> findAll() {
        List<Transfer> all = transferDao.findAll();
        return new ResponseResult<>(200,"查询成功",all,ResStatus.SUCCESS);
    }

    @Override
    public ResponseResult<List<Transfer>> findAllByWeek() {
        List<Transfer> daysContext = transferDao.findAllByWeek();
        return new ResponseResult<>(200,"查询成功",daysContext,ResStatus.SUCCESS);
    }

    @Override
    public ResponseResult<List<Transfer>> findAllByMonth() {

        List<Transfer> monthContext = transferDao.findAllByWeek();
        return new ResponseResult<>(200,"查询成功",monthContext,ResStatus.SUCCESS);
    }


    @Override
    public ResponseResult<List<Transfer>> findAllByDate(String date) {

        List<Transfer> all = transferDao.findAllByDate(date);
        return new ResponseResult<>(200,"查询成功",all,ResStatus.SUCCESS);
    }

    @Override
    public ResponseResult updateOne(Transfer transfer) {
        transferDao.updateOne(transfer);
        return new ResponseResult<>(200,"更新成功",null,ResStatus.SUCCESS);
    }

    @Override
    public BigDecimal eftSum() {
        BigDecimal sum = transferDao.sumAmount();
        return sum;
    }

    @Override
    public int eftCount() {
        int count = transferDao.timeTransfer();
        return count;
    }
}
